//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.anolesoft.twelveFactory.planManagement.controller;

import com.anolesoft.common.core.web.domain.AjaxResult;
import com.anolesoft.twelveFactory.planManagement.entity.Process;
import com.anolesoft.twelveFactory.planManagement.service.ProcessService;
import com.anolesoft.yr.demo.PageResult;
import com.anolesoft.yr.util.Constants;
import com.anolesoft.yr.util.HttpStatus;
import com.anolesoft.yr.util.PageData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping({"/twelveFactory/process"})
public class ProcessController {
    @Autowired
    private ProcessService processService;

    public ProcessController() {
    }
//    工艺计划
    @PostMapping(
            value = {"/listProcess"},
            produces = {"application/json"}
    )
    public AjaxResult selectProcess(@RequestBody Process process) {
        PageData<List<Process>> pageData = this.processService.listProcess(process);
        PageResult pageResult = new PageResult((List)pageData.getItems(), process.getPageSize(), process.getPageNo(), pageData.getTotal());
        return new AjaxResult(HttpStatus.SUCCESS,Constants.QUERY_SUCCESS_MESSAGE, pageResult);
    }
    @PostMapping(value = "/listPlanlsssued", produces = MediaType.APPLICATION_JSON_VALUE)
    public AjaxResult selectPlanIsssued(@RequestBody Process process) {
        PageData<List<Process>> pageData = this.processService.listPlanlsssued(process);
        PageResult pageResult = new PageResult((List)pageData.getItems(), process.getPageSize(), process.getPageNo(), pageData.getTotal());
        return new AjaxResult(HttpStatus.SUCCESS,Constants.QUERY_SUCCESS_MESSAGE, pageResult);
    }
    @PostMapping({"/insert"})
    public AjaxResult insert(@RequestBody Process process) {
        return new AjaxResult(HttpStatus.SUCCESS,Constants.CREATE_SUCCESS_MESSAGE, this.processService.Insert(process));
    }

    @PostMapping({"/update"})
    public AjaxResult update(@RequestBody Process process) {
        return new AjaxResult(HttpStatus.SUCCESS, Constants.MODIFY_SUCCESS_MESSAGE, this.processService.update(process));
    }

    @GetMapping({"/selectById"})
    public AjaxResult selectById(String objuid) {
        return new AjaxResult(HttpStatus.SUCCESS, "查询成功!", this.processService.selectById(objuid));
    }

    @PostMapping(
            value = {"/selectForJx"},
            produces = {"application/json"}
    )
    public AjaxResult selectForJx() {
        List<Process> processes = this.processService.selectForJx();
        return new AjaxResult(HttpStatus.SUCCESS, Constants.QUERY_SUCCESS_MESSAGE, processes);
    }

    @GetMapping(value = {"/delete"})
    public AjaxResult delete (String objuid) {
        return new AjaxResult(HttpStatus.SUCCESS,  Constants.DELETE_SUCCESS_MESSAGE, this.processService.delete(objuid));
    }
}
